package com.itpan.Service.Impl;

import com.itpan.Entity.Customer;
import com.itpan.Entity.Product;
import com.itpan.Entity.PurchaseOrderDetail;
import com.itpan.Entity.StatsByT;
import com.itpan.Mapper.PurchaseOrderDetailMapper;
import com.itpan.Service.PurchaseOrderDetailService;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PurchaseOrderDetailServiceImpl implements PurchaseOrderDetailService {
    @Autowired
    private PurchaseOrderDetailMapper purchaseOrderDetailMapper;
    @Override
    public List<PurchaseOrderDetail> getall() {
        List<PurchaseOrderDetail> list = purchaseOrderDetailMapper.getall();
        return list;
    }

    @Override
    public List<PurchaseOrderDetail> getallpage(Integer page, Integer pageSize) {
        RowBounds rowBounds=new RowBounds(page,pageSize);
        List<PurchaseOrderDetail> list = purchaseOrderDetailMapper.getallPage(rowBounds);
        return list;
    }

    @Override
    public List<PurchaseOrderDetail> getByMutil(PurchaseOrderDetail purchaseOrderDetail) {
        List<PurchaseOrderDetail> list = purchaseOrderDetailMapper.getbyMutil(purchaseOrderDetail);
        return list;
    }

    @Override
    public PurchaseOrderDetail getById(Long Id) {
        PurchaseOrderDetail purchaseOrderDetail = purchaseOrderDetailMapper.getById(Id);
        return purchaseOrderDetail;
    }

    @Override
    public List<PurchaseOrderDetail> getByProductId(String Id) {
        return  purchaseOrderDetailMapper.getProductByPId(Id);
    }


    @Override
    public void saveOne(PurchaseOrderDetail purchaseOrderDetail) {
        purchaseOrderDetailMapper.addOne(purchaseOrderDetail);
    }

    @Override
    public void saveAll(List<PurchaseOrderDetail> lsit) {
        purchaseOrderDetailMapper.addAll(lsit);
    }

    @Override
    public void update(PurchaseOrderDetail purchaseOrderDetail) {
        purchaseOrderDetailMapper.updateCustomerByID(purchaseOrderDetail);
    }

    @Override
    public void delete(Long Id) {
        purchaseOrderDetailMapper.deleteById(Id);
    }

    @Override
    public List<PurchaseOrderDetail> getMainpurchaseByMainId(Long Id) {
        return purchaseOrderDetailMapper.getMainPurchaseorder(Id);
    }

    @Override
    public List<PurchaseOrderDetail> getProductByPid(String Id) {
        return purchaseOrderDetailMapper.getProductByPId(Id);
    }

    @Override
    public List<StatsByT> getSumOfQuantityToproduct() {
        return purchaseOrderDetailMapper.getSumofQuantityToproduct();
    }

    //分组查询，统计各个订单主表的详细表项数
    @Override
    public List<StatsByT> getnumberCountoforder() {
        return purchaseOrderDetailMapper.getnumbercountOrder();
    }

    @Override
    public List<StatsByT> getavgpricebyproduct() {
        return purchaseOrderDetailMapper.getavgpricebyproduct();
    }
}
